package ltd.dujiabao.dex.rabbitmq.domain;

import lombok.Getter;

/**
 * @author : DuJiabao
 * @Project : common-delay-executor
 * @Time : 2024/3/23 17:28
 * @Desc :
 */
@Getter
public class RabbitDefinition {

    private final String emitQueueName;

    private final String dlxQueueName;

    private final String dlxExchangeName;
    private final String dlxBindingName;

    private final String listenerName;

    private final String listenerContainerName;

    public RabbitDefinition(String emitQueueName, String dlxQueueName, String dlxExchangeName, String dlxBindingName,
                            String listenerName, String listenerContainerName) {
        this.emitQueueName = emitQueueName;
        this.dlxQueueName = dlxQueueName;
        this.dlxExchangeName = dlxExchangeName;
        this.dlxBindingName = dlxBindingName;
        this.listenerName = listenerName;
        this.listenerContainerName = listenerContainerName;
    }

    public static RabbitDefinition create(String prefix) {
        String dlxExchangeName = prefix + ".exchange.dlx";
        String dlxQueueName = prefix + ".queue.dlx";
        String dlxBindingName = prefix + ".binding.dlx";
        String emitQueueName = prefix + ".queue";
        String listenerName = prefix + ".listener";
        String listenerContainerName = prefix + ".containerListener";
        return new RabbitDefinition(emitQueueName, dlxQueueName, dlxExchangeName, dlxBindingName, listenerName, listenerContainerName);
    }
}
